package org.mineground.commands.irc;

import java.util.ArrayList;
import java.util.List;
import org.jibble.pircbot.Colors;
import org.jibble.pircbot.User;
import org.mineground.Main;
import org.mineground.handlers.irc.CommandExecutor;
import org.mineground.handlers.irc.UserLevel;

public class Commands implements CommandExecutor {
    @Override
    public void onCommand(User sender, UserLevel level, String channel, String command, String args[]) {
	StringBuilder out = new StringBuilder();

	if (!channel.equalsIgnoreCase(Main.getInstance().getConfigHandler().getIrcDevChannel())) {
	    out.append(Colors.BLACK);
	    out.append(Colors.BOLD);
	    out.append("Commands: ");
	    out.append(Colors.NORMAL);
	    out.append(Colors.BLACK);
	    out.append("!players, !nplayers, !ntotalplayers, !msg, !pm, !online, !session, !ip");
            Main.getInstance().getIRCHandler().sendMessage(channel, out.toString());
            return;
	}

        out.append(Colors.BLACK);
        out.append(Colors.BOLD);
        out.append("Commands: ");
        out.append(Colors.NORMAL);
        out.append(Colors.BLACK);
	    
        List<String> commandNames = new ArrayList<String>(Main.getInstance().getIRCHandler().commandHandler.getCommands().keySet());
            
        for (String commandName : commandNames) {
            out.append("!");
            out.append(commandName);
            out.append(", ");
        }
            
        Main.getInstance().getIRCHandler().sendMessage(channel, out.toString().substring(0, out.toString().length() - 2));
    }
}